//
//  TabBarViewController.m
//  SmartCup
//
//  Created by Kendama on 2017/5/16.
//  Copyright © 2017年 DT. All rights reserved.
//

#import "TabBarViewController.h"

@interface TabBarViewController ()

@end

@implementation TabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setTabBarItem];

}


- (void)setTabBarItem
{
    
    HomeViewController *homeVC = [[HomeViewController alloc] init];
    homeVC.tabBarItem.title = @"首页";
    homeVC.navigationItem.title = @"我的水杯";
    
    RemindViewController *remindVC = [[RemindViewController alloc] init];
    remindVC.tabBarItem.title = @"提醒";
    remindVC.navigationItem.title = @"我的水杯";
    
    MeViewController *meVC = [[MeViewController alloc] init];
    meVC.tabBarItem.title = @"我的";
    meVC.navigationItem.title = @"用户中心";
    
    self.viewControllers = @[[self giveMeNavWithVC:homeVC andImgName:@"tab_button_home_nol" andSelectedImgName:@"tab_button_home_sel"],
                             [self giveMeNavWithVC:remindVC andImgName:@"tab_button_find_nor" andSelectedImgName:@"tab_button_find_sel"],
                             [self giveMeNavWithVC:meVC andImgName:@"tab_button_me_nol" andSelectedImgName:@"tab_button_me_sel"],
                            ];

    
}

/**
 *  快速创建Nav
 */
- (UINavigationController *)giveMeNavWithVC:(UIViewController *)VC andImgName:(NSString *)imgName andSelectedImgName:(NSString *)selImgName
{
    UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:VC];
//    nav.tabBarItem = [[UITabBarItem alloc] initWithTitle:VC.tabBarItem.title image:[self removeRendering:imgName] tag:0];
    nav.tabBarItem = [[UITabBarItem alloc] initWithTitle:VC.tabBarItem.title image:[self removeRendering:imgName] selectedImage:[self removeRendering:selImgName]];
//    [nav.tabBarItem setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:18],NSForegroundColorAttributeName:[UIColor grayColor]}
//                                  forState:UIControlStateNormal];
//    [nav.tabBarItem setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:18],NSForegroundColorAttributeName:[UIColor orangeColor]} forState:UIControlStateHighlighted];
//    [nav.tabBarItem setTitlePositionAdjustment:UIOffsetMake(0, -12)];
//    nav.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor yellowColor]};
    return nav;
}


/**
 *  返回取消渲染的image
 */
- (UIImage *)removeRendering:(NSString *)imageName
{
    UIImage * image = [UIImage imageNamed:imageName];
    return [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
}



@end
